package pub.guoxin.oops.manager.endpoint;


import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;
import pub.guoxin.oops.annotation.InjectUser;
import pub.guoxin.oops.constants.OopsPathConstants;
import pub.guoxin.oops.model.User;

import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.Map;

/**
 * Created by guoxin on 18-1-24.
 */
@Slf4j
//@Component
//@ServerEndpoint(OopsPathConstants.DEVICE_PATH + "/reg")
public class CommunicationEndpoint {

    @OnOpen
    public void openSession(Session session) {
        log.info("xxxxxxxxxxxxxxxxxxxxxxxxxxxx");
    }
//    @PathParam("username") String username,
    @OnMessage
    public void onMessage(Session session, String message,@InjectUser User user) throws IOException {
        session.getBasicRemote().sendText("用户: " + message);
        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    }

}